/*
 * create on 2012-5-30
 * Copy right (2012)
 * eking All rights reserved
 */
package com.myway.dto.insurance.domain;

import java.util.HashMap;

/**
 * 保险接口类型
 * @author 郑兴(zhengxing)
 *
 */
public enum InsuranceAPIType {
	//航信保险接口
	ABE("ABE"),
	//华泰保险接口
	DTWS("DTWS"),
	//阳光保险
	SUNSHINE("SUNSHINE"),
	//大众保险接口
	STARR("STARR");
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, InsuranceAPIType> map;

	/**
	 * Construct the hash map at load time
	 */
	static
	{
		map = new HashMap<String, InsuranceAPIType>();
		for ( InsuranceAPIType type : InsuranceAPIType.values() )
		{
			map.put( type.alias, type );
		}
	}

	InsuranceAPIType(String alias)
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>InsuranceAPIType</code> object holding the value of specified alias name
	 * 
	 * @param alias
	 * the alias name of the type
	 * 
	 * @return a <code>InsuranceAPIType</code> object holding the value represented by the alias name argument
	 */
	public static InsuranceAPIType valueOfAlias(String alias)
	{
		InsuranceAPIType type = map.get( alias );

		if ( type == null )
		{
			throw new IllegalArgumentException( "Unknown action alias [" + alias + "]" );
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias()
	{
		return this.alias;
	}
}
